<template>
  <h3 class="size">第三方设置</h3>
  <el-form style="background-color: rgb(255, 255, 255);height: 500px; " ref="ruleFormRef" :model="ruleForm"
    label-width="190px" class="demo-ruleForm" :size="formSize" status-icon>
    <el-form-item label="微信公众平台APPID:" prop="APP">
      <el-input style="width: 600px;" v-model="ruleForm.APP" />
    </el-form-item>
    <el-form-item label="微信公众平台APPSECRET:" prop="SECRET">
      <el-input style="width: 600px;" v-model="ruleForm.SECRET" />
    </el-form-item>
    <el-form-item label="微信TOKEN:" prop="TOKEN">
      <el-input style="width: 600px;" v-model="ruleForm.TOKEN" />
    </el-form-item>
    <el-form-item label="微信EncodingAESKey:" prop="EncodingAESKey">
      <el-input style="width: 600px;" v-model="ruleForm.EncodingAESKey" />
    </el-form-item>
    <el-form-item label="微信支付企业账号:" prop="accountnumber">
      <el-input style="width: 600px;" v-model="ruleForm.accountnumber" />
    </el-form-item>
    <el-form-item label="微信支付Key" prop="Key">
      <el-input style="width: 600px;" v-model="ruleForm.Key" />
    </el-form-item>
    <el-form-item label="微信企业付款证书部分路径:" prop="money">
      <el-input style="width: 600px;" v-model="ruleForm.money" />
    </el-form-item>
    <el-form-item label="支付宝APPID:" prop="Alipay">
      <el-input style="width: 600px;" v-model="ruleForm.Alipay" />
    </el-form-item>
    <el-form-item label="商户私钥:" prop="Privatekey">
      <el-input style="width: 600px;" v-model="ruleForm.Privatekey" />
    </el-form-item>
    <el-form-item label="支付宝公钥:" prop="Publickey">
      <el-input style="width: 600px;" v-model="ruleForm.Publickey" />
    </el-form-item>
  </el-form>
  <el-button class="btn" type="primary" @click="addSave">保存</el-button>
</template>

<script lang="ts" setup>
import { ref, reactive } from "vue";
import { onBeforeMount } from "vue";
import axios from "@/utils/http";
import { useStore, mapMutations } from "vuex";
import { ElMessage, ElMessageBox } from 'element-plus'

const dialogVisible = ref(false)
const dialogVisible1 = ref(false)
const pageSize = ref(99)

const data: any = ref("")
const store = useStore();

const formSize = ref("default");
const ruleForm = ref({
  APP: "",
  SECRET: "",
  TOKEN: "",
  EncodingAESKey: "",
  accountnumber: "",
  Key: "",
  money: "",
  Alipay: "",
  Privatekey: "",
  Publickey: "",


});

// 渲染全部数据
const addThirdData = mapMutations(["addThirdData"]).addThirdData.bind({
  $store: store,
});
// onBeforeMount(
//   () => {

//     addThirdData()


//   })
const addSave = () => {
  ElMessageBox.confirm(
    '确认保存吗？',
    '温馨提示',
    {
      confirmButtonText: '确认保存',
      cancelButtonText: '取消',

    }
  )
    .then(() => {
      ElMessage({
        type: 'success',
        message: '保存成功',
      })
      addThirdData({
        "alipayId": ruleForm.value.Alipay,
        "alipayPrivate": ruleForm.value.Privatekey,
        "privatePublic": ruleForm.value.Publickey,
        "weChatAppsecret": ruleForm.value.SECRET,
        "weChatCertificate": ruleForm.value.money,
        "weChatEncodingaex": ruleForm.value.EncodingAESKey,
        "weChatId": ruleForm.value.APP,
        "weChatPay": ruleForm.value.Key,
        "weChatPublicpay": ruleForm.value.accountnumber,
        "weChatToken": ruleForm.value.TOKEN
      })
      ruleForm.value.Alipay="",
         ruleForm.value.Privatekey="",
         ruleForm.value.Publickey="",
         ruleForm.value.SECRET="",
        ruleForm.value.money="",
         ruleForm.value.EncodingAESKey="",
        ruleForm.value.APP="",
        ruleForm.value.Key="",
        ruleForm.value.accountnumber="",
        ruleForm.value.TOKEN=""

    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消保存',
      })
    })



}
</script>

<style lang="less" scoped>
.size {
  color: rgb(66, 155, 255) !important;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.1;
}
</style> 